using BCW;
using UnityEngine;

public class RewardUIPanel : MonoBehaviour
{
	public Reward reward;

	public UILabel titleLabel;

	public UILabel amountLabel;

	public UIBasicSprite cashSprite;

	public UIBasicSprite coinsSprite;

	public UIBasicSprite productTexture;

	public void Init(Reward reward)
	{
		this.reward = reward;
		switch (this.reward.rewardGroup)
		{
		case RewardGroups.Non:
			base.gameObject.SetActive(false);
			break;
		case RewardGroups.Cash:
			SetCashRewardUI();
			break;
		case RewardGroups.Coins:
			SetCoinsRewardUI();
			break;
		case RewardGroups.Product:
			SetProductRewardUI();
			break;
		case RewardGroups.ProductConsumable:
			SetProductConsumableRewardUI();
			break;
		}
	}

	private void SetCashRewardUI()
	{
		amountLabel.gameObject.SetActive(true);
		amountLabel.text = reward.rewardAmount.ToString();
		cashSprite.gameObject.SetActive(true);
		coinsSprite.gameObject.SetActive(false);
		productTexture.gameObject.SetActive(false);
		SetTitle("Cash");
	}

	private void SetCoinsRewardUI()
	{
		amountLabel.gameObject.SetActive(true);
		amountLabel.text = reward.rewardAmount.ToString();
		coinsSprite.gameObject.SetActive(true);
		cashSprite.gameObject.SetActive(false);
		productTexture.gameObject.SetActive(false);
		SetTitle("Gold");
	}

	private void SetProductRewardUI()
	{
		productTexture = productTexture.ReplaceForCurrentPlatform();
		if (MarketController.Instance.GetProduct(reward.rewerdID) != null)
		{
			productTexture.gameObject.SetActive(true);
			productTexture.LoadTextureAndAlphaMask("AtlasShopGuns/", MarketController.Instance.GetProduct(reward.rewerdID).texture);
			amountLabel.gameObject.SetActive(false);
			coinsSprite.gameObject.SetActive(false);
			cashSprite.gameObject.SetActive(false);
			SetTitle(reward.rewerdID);
		}
	}

	private void SetProductConsumableRewardUI()
	{
		productTexture = productTexture.ReplaceForCurrentPlatform();
		if (MarketController.Instance.GetProduct(reward.rewerdID) != null)
		{
			productTexture.gameObject.SetActive(true);
			productTexture.LoadTextureAndAlphaMask("AtlasShopGuns/", MarketController.Instance.GetProduct(reward.rewerdID).texture);
			amountLabel.gameObject.SetActive(true);
			amountLabel.text = reward.rewardAmount.ToString();
			coinsSprite.gameObject.SetActive(false);
			cashSprite.gameObject.SetActive(false);
			SetTitle(reward.rewerdID);
		}
	}

	private void SetTitle(string title)
	{
		if (titleLabel != null)
		{
			titleLabel.text = title;
		}
	}

	public void ShowProductInMarket()
	{
		if (reward.rewardGroup == RewardGroups.Product || reward.rewardGroup == RewardGroups.ProductConsumable)
		{
			MarketController.Instance.ShowMarket(reward.rewerdID);
		}
	}
}
